﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Mvc;
using System.Web.Routing;
using Infancy.Core.Configuration.RouteConfig;
using System.Configuration;

namespace Infancy.Web
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            InitRouting(RouteTable.Routes);
        }

        private static void InitRouting(RouteCollection routes)
        {
            //routes.MapRoute("default",
            //    "{controller}/{action}",
            //    new { controller = "forum", action = "index" });

            RouteConfigurationSection section =
                (RouteConfigurationSection)ConfigurationManager.GetSection("RouteConfiguration");

            if (null == section)
            {
                throw new Exception("还没有配置你的Route规则,请配置你的Route规则");
            }

            RouteTable.Routes.RegisterRoutes(section);
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}